<template>
	<view class="login-container">
		<div class="login-item">
			<image src="/static/user_name.png" />
			<input class="uni-input" type="text" v-model="username" placeholder="请输入用户名" />
		</div>
		<div class="login-item">
			<image src="/static/password.png" />
			<input class="uni-input" password type="text" v-model="password" placeholder="请输入密码" />
		</div>
		<button style="margin: 60rpx 30rpx 0 30rpx;" type="primary" @click="login">登录</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				companyIndex: 0,
				companyList: [{
					value: '',
					label: '请选择公司'
				}],
				username: 'admin',
				password: '123456'
			}
		},
		onLoad() {
		},
		methods: {
			login() {
				if (!this.username) {
					uni.showToast({
						title: '请输入用户名',
						icon: 'none'
					});
					return;
				}
				if (!this.password) {
					uni.showToast({
						title: '请输入密码',
						icon: 'none'
					});
					return;
				}
				uni.showLoading({
					title: '登陆中'
				});
				uni.showToast({
					title: '登录成功',
					icon: 'success'
				});
				this.$storage.setUserId('test_user_id');
				setTimeout(() => {
					uni.reLaunch({
						url: '/pages/index/index'
					});
				}, 1500);
				
				// const path = `${global.$authHost}api/v1/server/login?companyId=${_companyId}&username=${this.username}&password=${this.password}&clientId=${global.$clientId}`;
				// uni.request({
				// 	url: path,
				// 	method: 'POST',
				// 	success: res => {
				// 		if (res.statusCode !== 200 || res.data.code !== 200) {
				// 			uni.showToast({
				// 				title: res.data.data || res.errMsg,
				// 				icon: 'none'
				// 			});
				// 			return;
				// 		}
				// 		this.$storage.setTenantId(res.data.data.tenantId);
				// 		this.$storage.setUserId(res.data.data.memeberId);
				// 		global.$userName = res.data.data.userName;
				// 		uni.hideLoading();
				// 		uni.showToast({
				// 			title: '登录成功',
				// 			icon: 'success'
				// 		});
				// 		setTimeout(() => {
				// 			uni.reLaunch({
				// 				url: '/pages/index/index'
				// 			});
				// 		}, 1500);
				// 	},
				// 	fail: error => {
				// 		uni.showToast({
				// 			title: error.errMsg || '登录失败',
				// 			icon: 'none'
				// 		});
				// 	}
				// });
			}
		}
	}
</script>

<style lang="scss" scoped>
	.login-container {
		padding-top: 100rpx;
		text-align: center;

		.logo {
			width: 160rpx;
			height: 160rpx;
			margin-bottom: 30rpx;
		}

		.login-item {
			background-color: #FFFFFF;
			border: 2rpx solid #D9D9D9;
			border-radius: 6rpx;
			display: flex;
			align-items: center;
			margin: 40rpx 30rpx;
			height: 86rpx;
		}

		.login-item image {
			width: 50rpx;
			height: 50rpx;
			margin: 0 20rpx;
		}

		.login-item .uni-input {
			border: none;
			text-align: left;
			height: 100%;
			padding: 0;
		}
	}
</style>

<style>
	page {
		background-color: #FFFFFF;
	}
</style>
